/// <reference types="cypress" />

Cypress.Commands.add('login', () => {
	cy.url().should('be.equal', 'http://localhost:3000/signin')
	cy.intercept('https://api.react-learning.ru/signin').as('signin')

	cy.get('input[name="email"]').type('ilya_polokhov@mail.ru')
	cy.get('input[name="password"]').type('666666')
	cy.get('form button[type="submit"]').contains('Войти').click()
	cy.url().should('be.equal', 'http://localhost:3000/')

	cy.wait('@signin').then((interception) => {
		return interception.response?.body.data._id
	})
})
